import Quick from ".";
import { WeaSelect, WeaLocaleProvider } from 'ecCom';
const { getLabel } = WeaLocaleProvider;

export default class Main extends Quick {
    state = {
        value: ''
    }
    getComponent = () => {
        const { value } = this.state;
        const { designerStore } = this.props;
        const sheetNames = designerStore.workbook.sheets.map(sheet => {
            var name = sheet.name();
            return {
                key: name,
                showname: name
            }
        });
        return (
            <div>
                <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@8dzbzh`}
                    style={{ minWidth: 200 }}
                    options={sheetNames}
                    value={value}
                    showSearch={true}
                    optionFilterProp="children"
                    onChange={v => this.setState({ value: v })}
                    placeholder={getLabel('511724','请选择Sheet名称')}
                />
            </div>
        )
    }
    getTitle = () => {
        return 'excel.getSheetFromName';
    }
    getScript = () => {
        return `excel.getSheetFromName('${this.state.value}');`
    }
}